<template>
  <div>
    <Headline
      :headline1="$t('m.AccessAdmin') + '  /  '"
      :headline2="$t('m.AccordingToTheDoorAuthorization')"
    />
    <a-card style="width: 100%">
      {{ $t("m.SelectArea") }}：

      <select-tree-area @checkData="areaSelect" />
      <a-input-search
        style="width: 200px; margin-left: 20px; margin-right: 20px"
        :placeholder="$t('m.PleaseEnterYourSearchTerms')"
        enter-button
        v-model="forminitial.key"
        @search="onSearch"
      />
      <a-checkbox style="margin-right: 20px" @change="checkChange">
        {{ $t("m.WhetherToDisplayChildNodes") }}
      </a-checkbox>
      <a-button type="primary" @click="goOut" icon="del">{{
        $t("m.ImportAndExportAuthorization")
      }}</a-button>
      <a-table
        size="small"
        style="margin-top: 20px"
        :columns="columns"
        :rowKey="(record, i) => i"
        :data-source="data"
        :pagination="false"
        bordered
        :row-selection="{
          onChange: onSelectChangeA,
          selectedRowKeys: selectedRowKeysListA,
        }"
      >
        <div slot="handle" slot-scope="text, tags, i">
          <a-button
            type="primary"
            style="margin-right: 10px"
            @click="delitem(text, tags, i)"
            icon="del"
            >{{ $t("m.DeleteTheAuthorized") }}</a-button
          >
          <a-button
            type="primary"
            @click="showitem(text, tags, i)"
            icon="del"
            >{{ $t("m.ShowTheAuthorized") }}</a-button
          >
        </div>
      </a-table>
      <a-pagination
        style="margin-top: 20px"
        show-size-changer
        :default-current="1"
        :total="totalA"
        @change="PagesA"
        :pageSizeOptions="['5', '10', '30', '40']"
        @showSizeChange="onShowSizeChangeA"
        class="pages"
      />
    </a-card>

    <a-drawer
      :title="$t('m.AuthorizationList')"
      placement="right"
      width="800px"
      :visible="visibleA"
      @close="onClose"
    >
      <a-input-search
        v-model="forminitialA.key"
        style="width: 200px; margin-left: 20px; margin-right: 20px"
        :placeholder="$t('m.PleaseEnterYourSearchTerms')"
        enter-button
        @search="onSearchA"
      />
      <a-button type="primary" icon="plus" @click="addControl">{{
        $t("m.TheNewAuthorization")
      }}</a-button>
      <!-- <a-button type="primary" icon="edit">修改授权</a-button>
      <a-button type="primary" icon="delete">删除授权</a-button> -->
      <a-table
        size="small"
        style="margin-top: 20px"
        :columns="columnsA"
        :rowKey="(record, i) => i"
        :data-source="dataA"
        :pagination="false"
        bordered
      >
        <div slot="handleA" slot-scope="text, tags, i">
          <a-button
            type="primary"
            style="margin-right: 10px"
            @click="delitemA(text, tags, i)"
            icon="del"
            >{{ $t("m.DeleteTheAuthorized") }}</a-button
          >
          <a-button
            type="primary"
            @click="edititemA(text, tags, i)"
            icon="del"
            >{{ $t("m.EditTheAuthorized") }}</a-button
          >
        </div>
      </a-table>
      <a-pagination
        style="margin-top: 20px"
        show-size-changer
        :default-current="1"
        :total="totalB"
        @change="PagesB"
        :pageSizeOptions="['5', '10', '30', '40']"
        @showSizeChange="onShowSizeChangeB"
        class="pages"
      />
    </a-drawer>
    <a-modal
      :title="$t('m.SelectPersonnel')"
      width="800px"
      :visible="visibleB"
      @ok="handleOkB"
      @cancel="handleCancelB"
      :footer="null"
      :cancelText="$t('m.Cancel')"
    :okText="$t('m.Ok')"
    >
      <a-steps :current="current">
        <a-step v-for="item in steps" :key="item.title" :title="item.title" />
      </a-steps>
      <div class="steps-content" v-if="current == 0 ? true : false">
        <select-tree style="margin-right: 20px" @checkData="changeTree" />
        <a-select
          style="width: 80px; margin-right: 20px"
          default-value="1"
          @change="treeChange"
        >
          <a-select-option value="1"> 职工 </a-select-option>
          <a-select-option value="2"> 学生 </a-select-option>
        </a-select>
        <a-input-search
          :placeholder="$t('m.Keywords')"
          v-model="forminitialB.key"
          style="width: 200px; margin-right: 20px"
          enter-button
          @search="onSearchB"
        />
        <a-checkbox @change="onChangeA">
          {{ $t("m.WhetherToDisplayChildNodes") }}
        </a-checkbox>

        <a-transfer
          style="margin-top: 20px"
          :locale="{ itemUnit: '项', itemsUnit: '项' }"
          :data-source="mockData"
          :target-keys="targetKeys"
          :show-search="showSearch"
          :filter-option="
            (inputValue, item) => item.title.indexOf(inputValue) !== -1
          "
          :show-select-all="false"
          @change="onChange"
        >
          <template
            slot="children"
            slot-scope="{
              props: { direction, filteredItems, selectedKeys },
              on: { itemSelectAll, itemSelect },
            }"
          >
            <a-table
              :row-selection="
                getRowSelection({
                  selectedKeys,
                  itemSelectAll,
                  itemSelect,
                })
              "
              :columns="direction === 'left' ? leftColumns : rightColumns"
              :data-source="filteredItems"
              bordered
              :pagination="direction === 'left'?ipagination:Rightipagination"
            />
          </template>
        </a-transfer>
      </div>
      <div class="steps-content" v-else>
        <a-table
          class="ant-table-tbody"
          style="margin-top: 20px"
          :columns="columnsB"
          :data-source="dataB"
          :rowKey="(record, i) => record.id"
          bordered
          size="small"
          :pagination="false"
          :scroll="{ x: 3500, y: 500 }"
          :row-selection="{
            onChange: onSelectChangeB,
            selectedRowKeys: selectedRowKeysListB,
          }"
        />
        <a-pagination
          style="margin-top: 10px"
          show-size-changer
          :default-current="1"
          :total="totalD"
          @change="PagesD"
          :pageSizeOptions="['5', '10', '30', '40']"
          @showSizeChange="onShowSizeChangeB"
          class="pages"
        />
      </div>
      <div class="steps-action">
        <a-button
          v-if="current < steps.length - 1"
          type="primary"
          @click="next"
        >
          {{$t('m.Next')}}
        </a-button>
        <a-button
          v-if="current == steps.length - 1"
          type="primary"
          @click="stepOk"
        >
          {{$t('m.Done')}}
        </a-button>
        <a-button v-if="current > 0" style="margin-left: 8px" @click="prev">
          {{$t('m.Previous')}}
        </a-button>
      </div>
    </a-modal>
    <a-modal
      :title="$t('m.ListOfTime')"
      :visible="visibleC"
  :cancelText="$t('m.Cancel')"
      :okText="$t('m.Ok')"
      @cancel="handleCancelC"
      width="1000px"
      @ok="handleOkC"
    >
      <a-table
        class="ant-table-tbody"
        style="margin-top: 20px"
        :columns="columnsB"
        :data-source="dataB"
        :rowKey="(record, i) => record.id"
        bordered
        size="small"
        :pagination="false"
        :scroll="{ x: 3500, y: 500 }"
        :row-selection="{
          onChange: onSelectChangeB,
          selectedRowKeys: selectedRowKeysListB,
        }"
      />
      <a-pagination
        style="margin-top: 10px"
        show-size-changer
        :default-current="1"
        :total="totalD"
        @change="PagesD"
        :pageSizeOptions="['5', '10', '30', '40']"
        @showSizeChange="onShowSizeChangeD"
        class="pages"
      />
    </a-modal>

    <Delete ref="del" @confirm="Isok" :dalete="deleteData"></Delete>
    <Delete ref="delA" @confirm="IsokA" :dalete="deleteData"></Delete>
  </div>
</template>

<script>
import Headline from "@/components/Headline";
import SelectTreeArea from "@/components/common/SelectTreeArea";
import SelectTree from "@/components/common/SelectTree";
import Delete from "@/components/Delete";
import { getAreaList, getTimeZoneList } from "@/api/perUnit";
import { getPerages } from "@/api/keraStase";
import { getStaffOrStudInfoList } from "@/api/faceRecognition";
import { authForDoorAndMan } from "@/api/entrance/cloudDoor";
import difference from "lodash/difference";

import {
  getDoorList,
  delAuthById,
  getAuthListById,
  delAuthForDoorAndMan,
  authForDoor,
  updateAuthForDoorAndMan,
} from "@/api/entrance/cloudDoor";
export default {
  name: "DoorAccredit",
  components: { Headline, Delete, SelectTreeArea, SelectTree },
  data() {
    return {
      totalE: 0,
      current: 0,
      steps: [
        {
          title: "First",
          content: "First-content",
        },
        {
          title: "Second",
          content: "Second-content",
        },
      ],
      mockData: [],
      targetKeys: [],
      selectedKeys: [],
      showSearch: false,
      disabled: false,
      leftColumns: [
        {
          title: "工号",
          dataIndex: "stafforstucode",
        },
        {
          title: "名称",
          dataIndex: "stafforstuname",
        },
        {
          title: "性别",
          dataIndex: "sex",
          customRender: function (text) {
            if (text == "1") {
              return "男";
            } else {
              return "女";
            }
          },
        },
        {
          title: "卡号",
          dataIndex: "cardno",
        },
        {
          title: "所属单位",
          dataIndex: "orgname",
        },
      ],
      rightColumns: [
        {
          dataIndex: "stafforstuname",
          title: "名称",
        },
      ],
      totalC: 0,
      dataA: [],
      totalA: 0,
      visibleC: false,
      visibleA: false,
      departmentList: [],
      data: [],
      dataB: [],
      columnsB: [
        {
          title: this.$t("m.Slotnumber"),
          dataIndex: "timeIndex",
        },
        {
          title: this.$t("m.SlotName"),
          dataIndex: "timeName",
        },
        {
          title: this.$t("m.timezone1"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTime",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTime",
            },
          ],
        },
        {
          title: this.$t("m.timezone2"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt1",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt1",
            },
          ],
        },
        {
          title: this.$t("m.timezone3"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt2",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt12",
            },
          ],
        },
        {
          title: this.$t("m.timezone4"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt3",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt13",
            },
          ],
        },
        {
          title: this.$t("m.timezone5"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt4",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt4",
            },
          ],
        },
        {
          title: this.$t("m.timezone6"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt5",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt5",
            },
          ],
        },
        {
          title: this.$t("m.timezone7"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt6",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt6",
            },
          ],
        },
        {
          title: this.$t("m.timezone8"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt7",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt7",
            },
          ],
        },
        {
          title: this.$t("m.timezone9"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt8",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt8",
            },
          ],
        },
        {
          title: this.$t("m.timezone10"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt9",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt9",
            },
          ],
        },
        {
          title: this.$t("m.timezone11"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt10",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt10",
            },
          ],
        },
        {
          title: this.$t("m.weekValue"),
          dataIndex: "weekValue",
          width: 300,
        },
        {
          title: this.$t("m.ValidUntil"),
          dataIndex: "endDate",
        },
      ],
      columns: [
        {
          title: this.$t("m.direction"),
          dataIndex: "inouttype",
          customRender: function (text) {
            if (text == "1") {
              return "进";
            } else {
              return "出";
            }
          },
        },
        { title: this.$t("m.Name"), dataIndex: "devname" },
        { title: this.$t("m.deviceNumber"), dataIndex: "machineid" },
        { title: this.$t("m.Controller"), dataIndex: "" },
        {
          title: this.$t("m.ReadHead"),
          dataIndex: "readhead",
          customRender: function (text) {
            if (text == "0") {
              return "1号读头";
            } else if (text == "1") {
              return "2号读头";
            } else if (text == "2") {
              return "3号读头";
            } else {
              return "4号读头";
            }
          },
        },
        { title: this.$t("m.SlotName"), dataIndex: "timename" },
        { title: this.$t("m.Slotnumber"), dataIndex: "timeindex" },
        {
          title: this.$t("m.Operation"),
          scopedSlots: { customRender: "handle" },
        },
      ],
      data: [],
      forminitial: {
        start: 0,
        limit: 10,
        page: 1,
        areaCode: "001",
        vChild: true,
        // key:'',
        // selectedIds:''
      },
      forminitialA: {
        start: 0,
        limit: 10,
        page: 1,
        key: "",
        doorReadHeadId: "",
      },
      deleteData: {
        titles: this.$t("m.DeleteThePrompt"),
        type: "warning",
        text: this.$t("m.AreYouSureToDeleteThisData"),
      },
      delheadId: "",
      columnsA: [
        {
          title: this.$t("m.jobnumber"),
          dataIndex: "stafforstuid",
        },
        {
          title: this.$t("m.Name"),
          dataIndex: "stafforstuname",
        },
        {
          title: this.$t("m.EndTime"),
          dataIndex: "enddate",
        },
        {
          title: this.$t("m.privilegedTime"),
          dataIndex: "createdate",
        },
        {
          title: this.$t("m.SlotName"),
          dataIndex: "timename",
        },
        {
          title: this.$t("m.Slotnumber"),
          dataIndex: "timeindex",
        },
        {
          title: this.$t("m.Operation"),
          scopedSlots: { customRender: "handleA" },
        },
      ],
      totalB: 0,
      delIds: "",
      visibleB: false,
      forminitialB: {
        start: 0,
        limit: 5,
        page: 1,
        key: "",
        infoType: 1,
        status: 1,
        vChild: false,
        ymOrgTreeCode: "",
      },
      dataC: [],
      columnsC: [
        {
          title: this.$t("m.jobnumber"),
          dataIndex: "stafforstucode",
        },
        {
          title: this.$t("m.Name"),
          dataIndex: "stafforstuname",
        },
        {
          title: this.$t("m.Sex"),
          dataIndex: "sex",
          customRender: function (text) {
            if (text == "1") {
              return "男";
            } else {
              return "女";
            }
          },
        },
        {
          title: this.$t("m.CardNumber"),
          dataIndex: "cardno",
        },
        {
          title: this.$t("m.AffiliatedUnit"),
          dataIndex: "orgname",
        },
      ],
      selectedRowKeysList: [],
      selectedRowKeysListA: [],
      selectedRowKeysListB: [],
      forminitialC: {
        page: 1,
        start: 0,
        limit: 10,
        key: "",
      },
      totalD: 0,
      forminitialE: {
        page: 1,
        start: 0,
        limit: 10,
        key: "",
      },
      dataE: [],
      columnsE: [
        {
          title: this.$t("m.Slotnumber"),
          dataIndex: "timeIndex",
        },
        {
          title: this.$t("m.SlotName"),
          dataIndex: "timeName",
        },
        {
          title: this.$t("m.timezone1"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTime",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTime",
            },
          ],
        },
        {
          title: this.$t("m.timezone2"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt1",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt1",
            },
          ],
        },
        {
          title: this.$t("m.timezone3"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt2",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt12",
            },
          ],
        },
        {
          title: this.$t("m.timezone4"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt3",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt13",
            },
          ],
        },
        {
          title: this.$t("m.timezone5"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt4",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt4",
            },
          ],
        },
        {
          title: this.$t("m.timezone6"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt5",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt5",
            },
          ],
        },
        {
          title: this.$t("m.timezone7"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt6",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt6",
            },
          ],
        },
        {
          title: this.$t("m.timezone8"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt7",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt7",
            },
          ],
        },
        {
          title: this.$t("m.timezone9"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt8",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt8",
            },
          ],
        },
        {
          title: this.$t("m.timezone10"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt9",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt9",
            },
          ],
        },
        {
          title: this.$t("m.timezone11"),
          children: [
            {
              title: this.$t("m.Start"),
              dataIndex: "startTimeExt10",
            },
            {
              title: this.$t("m.End"),
              dataIndex: "endTimeExt10",
            },
          ],
        },
        {
          title: this.$t("m.weekValue"),
          dataIndex: "weekValue",
          width: 300,
        },
        {
          title: this.$t("m.ValidUntil"),
          dataIndex: "endDate",
        },
      ],
      selectedRowKeysListE: [],
      forminitialF: {
        jsonData: [],
        doorReadHeadId: "",
        timeZoneId: "",
      },
      editState: false,
      forminitialG: {
        doorReadHeadId: "",
        timeZoneId: "",
        staffOrStudInfoId: "",
      },
      ipagination:{
        defaultPageSize:5,
        pageSizeOptions:['5','10','20'],
        showSizeChanger:true,
        // showQuickJumper:true,
        onShowSizeChange: this.pageSizeChange,
        onChange: this.pageChange,
        total:0
      },
      Rightipagination:{
         defaultPageSize:5,
      },
    };
  },
  created() {
    getAreaList()
      .then((res) => {
        this.departmentList = res.data;
      })
      .catch((err) => {
        console.log(err);
      });

    this.getdoorList();
  },
  methods: {
    
      pageSizeChange(val, pageNum){
      console.log(val, pageNum)
      this.forminitialB.limit = pageNum
      this.forminitialB.page = val
      this.forminitialB.start = pageNum*(val-1)
      this.getStaffOrStudInfoData ()
     
    },
    pageChange(page, val){
      this.forminitialB.page = page
      this.forminitialB.limit = val
      this.forminitialB.start = (page - 1) * val
      this.getStaffOrStudInfoData()
      console.log(page,val)

    },
    onSelectChangeE(e) {
      this.selectedRowKeysListE = e;
      console.log(this.selectedRowKeysListE);
    },

    onChange(targetKeys, direction, moveKeys) {
      console.log(this.mockData);
      console.log(targetKeys);
      this.targetKeys = targetKeys;
    },

    triggerShowSearch(showSearch) {
      this.showSearch = showSearch;
    },
    getRowSelection({ selectedKeys, itemSelectAll, itemSelect }) {
      return {
        onSelectAll(selected, selectedRows) {
          const treeSelectedKeys = selectedRows
            .filter((item) => !item.disabled)
            .map(({ key }) => key);
          const diffKeys = selected
            ? difference(treeSelectedKeys, selectedKeys)
            : difference(selectedKeys, treeSelectedKeys);
          itemSelectAll(diffKeys, selected);
        },
        onSelect({ key }, selected) {
          // console.log(key)
          itemSelect(key, selected);
        },
        selectedRowKeys: selectedKeys,
      };
    },
    handleOkC() {
      if (this.selectedRowKeysListB.length <= 0)
        return this.$message.warning("请选择时段列表");
      if (this.selectedRowKeysListB.length > 1)
        return this.$message.warning("时段列表只能选择一条");
      console.log(this.selectedRowKeysListB[0]);

      if (this.editState == false) {
        authForDoor({
          doorReadHeadId: this.selectedRowKeysListA[0],
          timeZoneId: this.selectedRowKeysListB[0],
        })
          .then((res) => {
            if (res.data.success == true) {
              this.$message.success(res.data.msg);
            } else {
              this.$message.warning(res.data.msg);
            }
          })
          .catch((err) => {
            this.$message.error("操作失败");
          });
      } else {
        this.forminitialG.timeZoneId = this.selectedRowKeysListB[0];
        updateAuthForDoorAndMan(this.forminitialG)
          .then((res) => {
            if (res.data.success == true)
              return this.$message.success(res.data.msg);
            if (res.data.success == false)
              return this.$message.warning(res.data.msg);
            console.log(res);
          })
          .catch((err) => {
            this.$message.error("操作失败");
          });
      }
      this.visibleC = false;
      this.selectedRowKeysListB = [];
    },
    next() {
      // console.log(this.targetKeys)
      // return
      console.log("a");
      this.getTimeScheme();
      if (this.targetKeys.length <= 0)
        return this.$message.warning("请选择人员信息");

      this.current++;
    },
    prev() {
      this.current--;
    },
    stepOk() {
      let doorReadHeadIdList = [];
      this.targetKeys.forEach((item) => {
        this.mockData.forEach((citem) => {
          if (citem.key == item) {
            doorReadHeadIdList.push(citem);
          }
        });
      });
      doorReadHeadIdList = doorReadHeadIdList.map((item) => {
        return {
          infotype: item.infotype,
          id: parseInt(item.key),
          orgname: item.orgname,
          property: item.property,
          sex: item.sex,
          stafforstucode: item.stafforstucode,
          stafforstuname: item.stafforstuname,
          status: item.status,
          ymorgid: item.ymorgid,
          ymorgtreecode: item.ymorgtreecode,
        };
      });
      this.forminitialF.jsonData = JSON.stringify(doorReadHeadIdList);
      if (this.selectedRowKeysListB.length <= 0)
        return this.$message.warning("请勾选时段");
      if (this.selectedRowKeysListB.length > 1)
        return this.$message.warning("只能勾选一个时段");
      this.forminitialF.timeZoneId = this.selectedRowKeysListB[0];
      authForDoorAndMan(this.forminitialF)
        .then((res) => {
          if (res.data.success == true) {
            this.$message.success(res.data.msg);
          }
          if (res.data.success == false) {
            this.$message.error(res.data.msg);
          }
        })
        .catch((err) => {
          this.$message.error("操作失败");
        });
      this.visibleB = false;
      this.current = 0;
      this.targetKeys = [];
      this.selectedRowKeysListB = [];
      this.getAuthListByIdList();
      console.log(this.selectedRowKeysListE);
    },
    getTimeScheme() {
      getTimeZoneList({ params: this.forminitialC })
        .then((res) => {
          this.totalD = res.data.total;
          res.data.data.forEach((item) => {
            let weekDayList = [];
            if (item.weekValue) {
              if (JSON.parse(item.weekValue).w0 == 1) {
                weekDayList.push("周日");
              }
              if (JSON.parse(item.weekValue).w1 == 1) {
                weekDayList.push("周一");
              }
              if (JSON.parse(item.weekValue).w2 == 1) {
                weekDayList.push("周二");
              }
              if (JSON.parse(item.weekValue).w3 == 1) {
                weekDayList.push("周三");
              }
              if (JSON.parse(item.weekValue).w4 == 1) {
                weekDayList.push("周四");
              }
              if (JSON.parse(item.weekValue).w5 == 1) {
                weekDayList.push("周五");
              }
              if (JSON.parse(item.weekValue).w6 == 1) {
                weekDayList.push("周六");
              }
              item.weekValue = weekDayList.join(" ");
            }
          });
          this.dataB = res.data.data;
          console.log(res.data.data);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    onShowSizeChangeD(page, limit) {
      this.forminitialC.page = page;
      this.forminitialC.limit = limit;
      this.getTimeScheme();
    },
    PagesD(page, pageSize) {
      this.forminitialC.limit = pageSize;
      this.forminitialC.page = page;
      this.forminitialC.start = (page - 1) * pageSize;
      this.getTimeScheme();
    },
    handleCancelC() {
      this.visibleC = false;
    },
    goOut() {
      if (this.selectedRowKeysListA.length <= 0)
        return this.$message.warning("清选择门禁或通道信息");
      if (this.selectedRowKeysListA.length > 1)
        return this.$message.warning("门禁或通道信息只能选择一条");
      this.editState = false;
      this.visibleC = true;
      this.getTimeScheme();
    },
    onSelectChangeB(selectedRowKeys, selectedRows) {
      // this.dataList = selectedRows[0];
      this.selectedRowKeysListB = selectedRowKeys;
      console.log(selectedRows[0]);
    },
    onSelectChangeA(selectedRowKeys, selectedRows) {
      // this.dataList = selectedRows[0];
      this.selectedRowKeysListA = selectedRowKeys;
      console.log(selectedRows[0]);
    },
    onSelectChange(selectedRowKeys, selectedRows) {
      // this.dataList = selectedRows[0];
      this.selectedRowKeysList = selectedRowKeys;
      console.log(selectedRows[0]);
    },
    onChangeA(e) {
      console.log(e.target.checked);
      this.forminitialB.vChild = e.target.checked;
      this.getStaffOrStudInfoData();
    },
    onSearchB() {
      this.getStaffOrStudInfoData();
    },
    treeChange(e) {
      this.forminitialB.infoType = e;
      this.getStaffOrStudInfoData();
      console.log(e);
    },
    handleCancelB() {
      this.current = 0;
      this.targetKeys = [];
      this.selectedRowKeysListB = [];
      this.visibleB = false;
    },
    changeTree(e) {
      this.forminitialB.ymOrgTreeCode = e.ymorgtreecode;
      this.getStaffOrStudInfoData();
      console.log(e);
    },
    handleOkB() {},
    getStaffOrStudInfoData() {
      getStaffOrStudInfoList({ params: this.forminitialB })
        .then((res) => {
          this.ipagination.total = res.data.total
          this.mockData = res.data.data.map((item) => {
            return {
              key: item.id + "",
              infotype: item.infotype,
              orgname: item.orgname,
              property: item.property,
              sex: item.sex,
              stafforstucode: item.stafforstucode,
              stafforstuname: item.stafforstuname,
              ymorgid: item.ymorgid,
              status: item.status,
              ymorgtreecode: item.ymorgtreecode,
            };
          });
          this.dataC = res.data.data;
          // this.totalC = res.data.total
          console.log(res);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    addControl() {
      this.visibleB = true;
      getPerages({ params: { orgType: 1 } })
        .then((res) => {
          console.log(res.data[0]);
          this.forminitialB.ymOrgTreeCode = res.data[0].ymorgtreecode;
          this.getStaffOrStudInfoData();
        })
        .catch((err) => {
          console.log(err);
        });
    },
    IsokA() {
      delAuthForDoorAndMan(this.delIds)
        .then((res) => {
          if (res.data.success == true) {
            this.getAuthListByIdList();
            this.$message.success(res.data.msg);
          }
          if (res.data.success == false) {
            this.$message.error(res.data.msg);
          }
          console.log(res);
        })
        .catch((err) => {
          this.$message.error("操作失败");
          console.log(err);
        });
      this.$refs.delA.visible = false;
    },
    edititemA(text, tags, i) {
      this.editState = true;
      this.visibleC = true;
      this.forminitialG.staffOrStudInfoId = tags.id;
      this.getTimeScheme();
      console.log(tags);
    },
    delitemA(text, tags, i) {
      this.delIds = tags.id;
      console.log(tags);
      this.$refs.delA.visible = true;
    },
    onSearchA() {
      this.getAuthListByIdList();
    },
    onClose() {
      this.visibleA = false;
    },
    getAuthListByIdList() {
      getAuthListById({ params: this.forminitialA })
        .then((res) => {
          this.dataA = res.data.data;
          this.totalB = res.data.total;
          console.log(res);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    onShowSizeChangeC(page, limit) {
      this.forminitialB.page = page;
      this.forminitialB.limit = limit;
      this.getStaffOrStudInfoData();
    },
    PagesC(page, pageSize) {
      this.forminitialB.limit = pageSize;
      this.forminitialB.page = page;
      this.forminitialB.start = (page - 1) * pageSize;
      this.getStaffOrStudInfoData();
    },
    showitem(text, tags, i) {
      this.forminitialF.doorReadHeadId = tags.id;
      this.forminitialG.doorReadHeadId = tags.id;
      console.log(tags);
      this.visibleA = true;
      this.forminitialA.doorReadHeadId = tags.doorreadheadid;
      this.getAuthListByIdList();
    },
    Isok() {
      delAuthById({ doorReadHeadId: this.delheadId })
        .then((res) => {
          if (res.data.success == true) {
            this.getdoorList();
            this.$message.success(res.data.msg);
          }
          if (res.data.success == false) {
            this.$message.error(res.data.msg);
          }
        })
        .catch((err) => {
          this.$message.error("操作失败");
        });
      this.$refs.del.visible = false;
      console.log("a");
    },
    delitem(text, tags, i) {
      this.$refs.del.visible = true;
      this.delheadId = tags.doorreadheadid;
    },
    onShowSizeChangeB(page, limit) {
      this.forminitialA.page = page;
      this.forminitialA.limit = limit;
      this.getAuthListByIdList();
    },
    PagesB(page, pageSize) {
      this.forminitialA.limit = pageSize;
      this.forminitialA.page = page;
      this.forminitialA.start = (page - 1) * pageSize;
      this.getAuthListByIdList();
    },
    onShowSizeChangeA(page, limit) {
      this.forminitial.page = page;
      this.forminitial.limit = limit;
      this.getdoorList();
    },
    PagesA(page, pageSize) {
      this.forminitial.limit = pageSize;
      this.forminitial.page = page;
      this.forminitial.start = (page - 1) * pageSize;
      this.getdoorList();
    },
    getdoorList() {
      getDoorList({ params: this.forminitial })
        .then((res) => {
          this.data = res.data.data;
          this.totalA = res.data.total;
          console.log(res.data.data);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    checkChange(e) {
      console.log(e.target.checked);
      this.forminitial.vChild = e.target.checked;
      this.getdoorList();
    },
    onSearch() {
      this.getdoorList();
    },
    areaSelect(e) {
      this.forminitial.areaCode = e.areacode;
      this.getdoorList();
      console.log(e);
    },
  },
};
</script>

<style scoped lang="scss">
.steps-content {
  margin-top: 16px;
  border: 1px dashed #e9e9e9;
  border-radius: 6px;
  background-color: #fafafa;
  min-height: 200px;
  /* text-align: center; */
  padding-top: 20px;
  padding-left: 10px;
  padding-right: 10px;
}

.steps-action {
  margin-top: 24px;
}
/deep/.ant-table-tbody > tr > td {
    padding: 16px 10px !important;
}
</style>